function changeDataType(obj){
  let str = ''
  if(typeof obj == 'object'){
    for(let i in obj){
      if(typeof obj[i] != 'function' && typeof obj[i] != 'object'){
        str += i + '=' + obj[i] + '&' ;
      }else if (typeof obj[i] == 'object'){
        nextStr = '';
        str += changeSonType(i, obj[i])
      }
    }
  }
  return str.replace(/&$/g, '');
}
function changeSonType(objName, objValue){
  if(typeof objValue == 'object'){
    for(let i in objValue){
      if(typeof objValue[i] != 'object'){
        let value = objName + '[' + i + ']=' + objValue[i];
        nextStr += encodeURI(value) + '&';
      }else{
        changeSonType(objName + '[' + i + ']', objValue[i]);
      }
    }
  }
  return nextStr;
}

function checkLogin(vm,fn,flag){
  vm.$root.userPromiss.then(data => {
    if (vm.$root.userInfo && vm.$root.userInfo.id) {
        vm.userInfo = vm.$root.userInfo
        fn && fn()
    } else if(!flag){
      vm.$router.push({path: "/login/login"});
    }
  })

}

function isWechat(){
  var ua = navigator.userAgent.toLowerCase();
  if(ua.match(/MicroMessenger/i) == 'micromessenger'){
    return true;
  }else{
    return false;
  }
}

function isIos(){
  let web = navigator.userAgent;
  return  !!web.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
}
